menuList[2].onclick();


// 点击返回上一页
function returnFun(){
    window.history.back();  
}

//询问是否通过或下架一个商品
function openPassGoodsFun(e){
    e=e || window.event;
    var target=e.target || e.srcElement;
    goodsid = target.getAttribute("name")
    userid = target.getAttribute("userid")
    let flag = target.getAttribute("flag");
    if(flag=='2'){
        pointFun({
            code:10,
            msg:"是否通过该商品的审核"
        })
    }else if(flag==1){
        let reasonWin = cl("reasonWin");
        let covers = cl("covers");
        reasonWin.style.display="block"
        covers.style.display="block"
    }
    console.log(e.target);
    console.warn(target.getAttribute('name'));
} 
function alertInputs(){
    var str = prompt("请输入拒绝理由");
    if(str){
        alert(str);
    }
}
// alertInputs();
// prompt("请输入拒绝理由");
//通过一个商品
function passGoodsFun(){
    axios({
        url:'/admin/goods/passAGood',
        method:'PATCH',
        params:{
            goodsId:goodsid
        }
    })
    .then(data => {
        console.log(data);
        if(data.data.code==20000){
            closeFunUser();
            explain({
                code:1,
                msg:"通过审核成功",
                time:3000
            })
            window.location.reload();
        }
    })
    .catch(err => {
        console.log(err);
    })
}
// 打开商品下架理由面板
function openUndercarriageGoodsFun(e){
    e=e || window.event;
    var target=e.target || e.srcElement;
    goodsid = target.getAttribute("name")
    userid = target.getAttribute("userid")
    console.log(userid);
    let flag = target.getAttribute("flag");
    if(flag==1){
        pointFun({
            code:10,
            msg:"是否通过该商品的审核"
        })
    }
}
// 下架一个商品
function undercarriageGoodsFun(){
    let reasonWrap = cl("reasonWrap");
    console.log(reasonWrap.value);
    console.log(userid);
    axios({
        url:'/admin/goods/refuseAGood',
        method:'POST',
        params:{
            goodsId:goodsid,
            comment :reasonWrap.value,
            userId :userid 
        }
    })
    .then(data => {
        console.log(data);
        if(data.data.code==20000){
            closeFunUser();
            explain({
                code:1,
                msg:"下架成功成功",
                time:3000
            })
            window.location.reload();
        }
    })
    .catch(err => {
        console.log(err);
    })
}
function closeFunUser(){
    let reasonWin = cl("reasonWin");
    let covers = cl("covers");
    reasonWin.style.display="none"
    covers.style.display="none"
}